import Fetch from './fetch';
// import { Fetch } from './fetch';
// example
export const monitorList = (method) => Fetch({ url: '/monitorlist', method });

//****登陆****
export const login = (data) => Fetch({ url: '/user/login/', method: 'POST', data });
//退出登录
export const logout = (data) => Fetch({ url: '/user/logout/', method: 'POST', data });

// 注册
export const register = (data) => Fetch({ url: '/user/register/', method: 'POST', data });
//****接入业务系统(新建任务组)****
export const targetAdd = (data) => Fetch({ url: '/target/group/add/', method: 'POST', data });
//获取业务系统列表
export const getTargetList = (data) => Fetch({ url: '/target/list/', method: 'GET', data });
//获取业务系统配置
export const getTargetInfo = (data) => Fetch({ url: `/target/${data}/`, method: 'GET' });
//删除业务系统
export const delTarget = (data) => Fetch({ url: `/target/del/`, method: 'DELETE', data });
//获取任务组配置
export const getGroupInfo = (data) => Fetch({ url: `/target/group/${data}/`, method: 'GET' });
//编辑业务系统配置
export const putTarget = ({ data, id }) => Fetch({ url: `/target/${id}/`, method: 'PUT', data });
//编辑业务系统名称
export const putTargetName = ({ data, id }) =>
  Fetch({ url: `/target/${id}/rename/`, method: 'PUT', data });
//编辑任务组配置
export const putGroup = ({ data, id }) =>
  Fetch({ url: `/target/group/${id}/`, method: 'PUT', data });
//立即下发任务（批量）
export const putRescan = (data) => Fetch({ url: `/target/rescan/`, method: 'PUT', data });
//立即下发任务(任务组)
export const putGroupRescan = (data) =>
  Fetch({ url: `/target/group/rescan/`, method: 'PUT', data });

//获取任务队列
export const getTask = (data) => Fetch({ url: `/task/list/`, method: 'GET', data });
//获取任务队列统计
export const getTaskTotal = () => Fetch({ url: `/task/summary/`, method: 'GET' });
//取消任务队列
export const cancelTask = (data) => Fetch({ url: `/task/cancel/`, method: 'PUT', data });
//获取任务组统计
export const getGroupTotal = () => Fetch({ url: `/target/group/summary/`, method: 'GET' });
//获取任务组
export const getTaskGroup = (data) => Fetch({ url: `/target/group/list/`, method: 'GET', data });
//获取任务组业务系统信息
export const getTaskList = (data) =>
  Fetch({ url: `/target/group/${data}/targets/list/`, method: 'GET' });

//编辑任务组状态
export const changeTaskStatus = ({ data, id }) =>
  Fetch({ url: `/target/group/${id}/status/`, method: 'PUT', data });
//删除任务组
export const delTaskGroup = (data) => Fetch({ url: `/target/group/del/`, method: 'DELETE', data });
//任务组查看业务系统监测列表
export const getGroupList = ({ type, id, data }) =>
  Fetch({ url: `/target/group/${id}/${type}/list/`, method: 'GET', data });
//任务组查看业务系统风险占比
export const getGroupPercent = ({ type, id }) =>
  Fetch({ url: `/target/group/${id}/${type}/statistics/`, method: 'GET' });
//任务组查看业务系统top5
export const getTopData = ({ type, id }) =>
  Fetch({ url: `/target/group/${id}/${type}/top/`, method: 'GET' });
//任务组可用性结果趋势
export const getTrend = ({ type, id, data }) =>
  Fetch({ url: `/target/group/${id}/${type}/trend/`, method: 'GET', data });

//TODO:
//  获取mfa
export const getMfaCode = (method) => Fetch({ url: '/account/mfa_qr/', method });
// 绑定mfa
export const bindMfa = (method, data) => Fetch({ url: '/account/mfa_bind/', method, data });
// 解绑mfa
export const unbindMfa = (method, data) => Fetch({ url: '/account/mfa_unbind/', method, data });
// 获取用户信息
export const getUserInfoDetail = (method) => Fetch({ url: '/account/user_info/', method });
// 远程协助
export const remoteHelp = (method, data) =>
  Fetch({ url: '/system/support/', method, data: method === 'GET' ? {} : data });
// 产品信息
export const productInfo = (method) => Fetch({ url: '/system/license/', method });
// 产品信息 header
export const productInfoHeader = (method) =>
  Fetch({
    url: '/system/license/',
    method,
    isheaders: false,
  });
// 上传产品证书
export const uploadProductLicense = (method, data) =>
  Fetch({ url: '/system/license/', method, data, file: true });
// 上传产品证书 无header
export const uploadProductLicenseNoToken = (method, data) =>
  Fetch({ url: '/system/license/', method, data, file: true, isheaders: false });
// 系统版本信息/数据版本信息
export const modifySysUpdate = (method, data, file) =>
  Fetch({ url: '/system/update/', method, data, file });
// HA配置
export const modifySysHa = (method, data) =>
  Fetch({ url: '/system/support/', method, data: method === 'GET' ? {} : data });
// 系统配置-测试
export const modifySysPing = (data) => Fetch({ url: '/system/ping/', method: 'POST', data });
// 运行模式
export const modifySysMode = (method, data) =>
  Fetch({ url: '/system/mode/', method, data: method === 'GET' ? {} : data });
// snmp配置
export const SnmpConfigModify = (method, data) =>
  Fetch({ url: '/system/snmp/', method, data: method === 'GET' ? {} : data });
// 路由配置-列表、添加、删除（批量）
export const SystemRoute = (method, data) => Fetch({ url: '/system/route/', method, data });
// 系统配置
export const modifySysConfig = (method, data) => Fetch({ url: '/system/config/', method, data });
// 系统最近更新时间
export const getNodeUpdate = (data) => Fetch({ url: '/system/node-upat/', method: 'GET', data });
// 系统开机持续时间
export const getOnlineTime = (data) => Fetch({ url: '/system/node-uptime/', method: 'GET', data });

// 接口信息
export const interfaceInfo = (method, data) => Fetch({ url: '/system/network/', method, data });
// NTP时间同步
export const ntpConfig = (method, data) => Fetch({ url: '/system/ntp/', method, data });
// 重启/关闭设备
export const modifySysReboot = (data) => Fetch({ url: '/system/manage/', method: 'POST', data });
// 校验mfa
export const validateMfa = (method, data, bool = false) =>
  Fetch({ url: '/account/mfa_validate/', method, data, isheaders: bool });

// 系统集群
export const getSystemNode = () => Fetch({ url: '/system/node/', method: 'GET' });
// 操作节点
export const operateNodeApi = (method, data) =>
  Fetch({ url: '/system/node/change/', method, data });
// 添加节点
export const addNodeConfig = (method, data) => Fetch({ url: '/system/node/', method, data });
// 系统状态
export const modifySysStatus = (data) => Fetch({ url: '/system/status/', method: 'GET', data });

// 日志中心
// 获取磁盘阀值

export const getSystemDisk = (data) =>
  Fetch({ url: '/system/ddisk/', method: 'GET', data, isheaders: false });
// 操作日志模块
export const operateLogModule = (method, query) =>
  Fetch({ url: `/log/config/?module=${query}`, method });
// 操作日志列表
export const operateLogList = (method, data) => Fetch({ url: `/log/operation/`, method, data });
// 登录日志
export const loginLog = (method, data) => Fetch({ url: `/log/login/`, method, data });
// 日志下载新
export const downloadLogNew = (data) =>
  Fetch({
    url: `/log/download/`,
    method: 'POST',
    file: false,
    blob: { responseType: 'blob' },
    data,
  });
// 日志下载
export const downloadLog = (method, blob, type, time, text) =>
  Fetch({ url: `/log/protection/?type=${type}&date=${time}`, method, file: false, blob, text });
// 日志批量删除新
export const batchDeleteLogNew = (data) => Fetch({ url: '/log/delete/', method: 'POST', data });
// 批量删除
export const batchDeleteLog = (method, data) => Fetch({ url: '/log/protection/', method, data });
// 防护日志
export const defenseLogDown = (method, data) =>
  Fetch({ url: '/log/protection/list/', method, data });
//获取下拉域名
export const getDomainList = (method) => Fetch({ url: '/assets/site/dns_expand/', method });
// 站锁日志
export const siteLockLogApi = (method, data) => Fetch({ url: `/log/lock/`, method, data });
// syslog配置
export const sysLogConfig = (method, data) => Fetch({ url: '/log/syslog/', method, data });
// 用户信息查询
export const queryUser = (method, query) =>
  Fetch({
    url: `/account/manage_user_info/?page=${query.page || 1}&pageSize=${query.pageSize || 10}`,
    method,
  });
// 冻结用户
export const freezeUser = (method, data) =>
  Fetch({ url: '/account/manage_freeze_user/', method, data });
// 启用用户
export const restartUser = (method, data) =>
  Fetch({ url: '/account/manage_active_user/', method, data });
// 普通用户修改密码
export const modifyNormalPwd = (method, data) =>
  Fetch({ url: '/account/manage_change_pw/', method, data });
// 修改密码
export const modifyPwd = (method, data) => Fetch({ url: '/account/change_pw/', method, data });
//用户token时间设置
export const putTokenTime = (data) =>
  Fetch({
    url: `/gc/token/`,
    method: 'PUT',
    data,
  });
//查询指定用户详情
export const getAccount = (data) =>
  Fetch({
    url: `/account/${data}/detail/`,
    method: 'GET',
  });
//编辑指定用户详情
export const putAccount = ({ data, id }) =>
  Fetch({
    url: `/account/${id}/detail/`,
    method: 'PUT',
    data,
  });
//获取当前用户信息
export const getUserInfo = (data) =>
  Fetch({
    url: `/account/user_info/`,
    method: 'GET',
    data,
  });
//编辑当前用户信息
export const putUserInfo = (data) =>
  Fetch({
    url: `/account/user_info/`,
    method: 'PUT',
    data,
  });
//删除用户
export const delUser = (data) =>
  Fetch({
    url: `/account/delete/batch/`,
    method: 'DELETE',
    data,
  });
/**  */
//漏洞折线图数据
export const vulLine = (data) => Fetch({ url: '/vul/line/', method: 'GET', data });
//漏洞饼图数据
export const vulPie = (data) => Fetch({ url: '/vul/pie/', method: 'GET', data });
//漏洞枚举接口
export const vulEnums = (data) => Fetch({ url: '/vul/enums/', method: 'GET', data });
//漏洞列表筛选
export const vulList = (data) => Fetch({ url: '/vul/list/', method: 'GET', data });
//漏洞最新时间
export const vulVst = (data) => Fetch({ url: '/vul/vst/', method: 'GET', data });
/**  */
//敏感词类型数量统计
export const kwCount = (data) => Fetch({ url: '/keyword/count/', method: 'GET', data });
//敏感词各类型数据列表
export const kwList = (id) => Fetch({ url: `/keyword/${id}/`, method: 'GET' });
//替换 敏感词各类型数据列表
export const kwPut = ({ data, id }) => Fetch({ url: `/keyword/${id}/`, method: 'PUT', data });
//白名单敏感词列表
export const Whitekey = (data) => Fetch({ url: '/keyword/whitekey', method: 'GET', data });
//白名单敏感词新增
export const whitekeyAdd = (data) => Fetch({ url: '/keyword/whitekey/', method: 'POST', data });
//白名单敏感词删除
export const whitekeyDel = (data) => Fetch({ url: '/keyword/whitekey/', method: 'DELETE', data });

//自定义模板列表
export const customModuleList = (data) =>
  Fetch({ url: '/strategy/profile/template/list/', method: 'GET', data });
//自定义模板查询
export const customModuleQuery = (id) =>
  Fetch({ url: `/strategy/profile/template/${id}/`, method: 'GET' });
//自定义模板新增
export const customModuleAdd = (data) =>
  Fetch({ url: '/strategy/profile/template/create/', method: 'POST', data });
//自定义模板修改
export const customModuleUpdate = ({ data, id }) =>
  Fetch({ url: `/strategy/profile/template/${id}/`, method: 'PUT', data });
//自定义模板删除
export const customModuleDel = (data) =>
  Fetch({ url: '/strategy/profile/template/delete/batch/', method: 'DELETE', data });
//漏洞插件列表
export const pluginList = (data) => Fetch({ url: '/vul/plugin/list/', method: 'GET', data });

//****告警中心****
//消息列表
export const getMailList = (data) =>
  Fetch({ url: `/warn/mail/list/`, method: 'GET', data, refre: false });
//修改消息状态
export const setMailStatus = (data) => Fetch({ url: `/warn/mail/status/`, method: 'PUT', data });
//删除消息
export const delMails = (data) => Fetch({ url: `/warn/mail/del/`, method: 'DELETE', data });
//全部已读消息
export const setAllMails = (data) => Fetch({ url: `/warn/mail/update-all/`, method: 'PUT', data });
//全部删除消息
export const delAllMails = (data) => Fetch({ url: `/warn/mail/del-all/`, method: 'DELETE', data });

//****数据报表****
//监测-详情-获取监测结果列表
export const getScanResult = ({ id, type, data }) =>
  Fetch({ url: `/target/${id}/${type}/event/list/`, method: 'GET', data });
//任务组-详情-获取监测结果列表
export const getGroupResult = ({ id, data }) =>
  Fetch({ url: `/session/${id}/event/list/`, method: 'GET', data });
//监测列表-附录/api/v1/target/{target_id}/appendix/
export const getAppendix = (id) => Fetch({ url: `/target/${id}/appendix/`, method: 'GET' });
//监测列表-附录 任务组进入
export const getAppendixGroup = (id) => Fetch({ url: `/session/${id}/appendix/`, method: 'GET' });
//监测列表-详情-信息
export const getsite = (id) => Fetch({ url: `/target/${id}/site/`, method: 'GET' });
// 修改事件状态
export const eventBatch = (data) => Fetch({ url: `/event/batch/`, method: 'PUT', data });
// web漏洞验证
export const vildVul = (data) => Fetch({ url: `/task/vul/verification/`, method: 'POST', data });
// 任务组-可用性报表-本地
export const getLocalReport = (id, data) =>
  Fetch({ url: `/target/${id}/availability/normal/event/list/`, method: 'GET', data });
// 任务组-可用性报表-云端
export const getCloudReport = (id, data) =>
  Fetch({ url: `/target/${id}/availability/cloud/event/list/`, method: 'GET', data });
//报表-最新监测结果基本信息(监进综述)
export const AlleventSole = (id) => Fetch({ url: `/target/${id}/summary/`, method: 'GET' });
//报表-最新监测结果基本信息(组进综述)
export const AlleventGroup = (id) => Fetch({ url: `/session/${id}/summary/`, method: 'GET' });
//获取搜索监测历史
export const getTimes = ({ id, type }) =>
  Fetch({ url: `/target/${id}/${type}/session/search/`, method: 'GET' });
//高危漏洞top10
export const vulTop10 = (id) => Fetch({ url: `/target/${id}/vul/top/`, method: 'GET' });
//立即下发任务（业务系统指定任务类型）
export const putTypeRescan = ({ id, type }) =>
  Fetch({ url: `/target/${id}/${type}/rescan/`, method: 'PUT' });
//报表导出
export const getReport = ({ id }) =>
  Fetch({
    url: `/report/report/${id}/`,
    method: 'GET',
    file: false,
    blob: { responseType: 'blob' },
  });
//告警列表
export const warnList = (data) =>
  Fetch({
    url: `/warn/list/`,
    method: 'GET',
    data,
  });
//创建告警联系人
export const warnAddUser = (data) =>
  Fetch({
    url: `/warn/receiver/add/`,
    method: 'POST',
    data,
  });
//编辑告警联系人
export const putWarnUser = ({ receiver_id, data }) =>
  Fetch({
    url: `/warn/receiver/${receiver_id}/`,
    method: 'PUT',
    data,
  });
//查询告警联系人
export const getWarnUser = ({ receiver_id }) =>
  Fetch({
    url: `/warn/receiver/${receiver_id}/`,
    method: 'GET',
  });
//批量删除告警联系人
export const delWarnUser = (data) =>
  Fetch({
    url: `/warn/receiver/del/`,
    method: 'DELETE',
    data,
  });
//获取告警联系人列表
export const getWarnUserList = (data) =>
  Fetch({
    url: `/warn/receiver/list/`,
    method: 'GET',
    data,
  });
//查询告警邮件配置
export const getWarnSite = () =>
  Fetch({
    url: `/warn/email/`,
    method: 'GET',
  });
//编辑告警邮件配置
export const putWarnSite = (data) =>
  Fetch({
    url: `/warn/email/`,
    method: 'PUT',
    data,
  });
//发送测试邮件
export const postWarnTest = (data) =>
  Fetch({
    url: `/warn/email/test/`,
    method: 'POST',
    data,
  });
//最近一周告警
export const getWarnWeek = () =>
  Fetch({
    url: `/warn/summary/week/`,
    method: 'GET',
  });
//今日告警统计
export const getWarnDay = () =>
  Fetch({
    url: `/warn/summary/day/`,
    method: 'GET',
  });

//新增备份
export const backupNew = (data) =>
  Fetch({ url: `/system/backup-recovery/backup/`, method: 'POST', data });
//备份列表
export const backupList = (data) =>
  Fetch({ url: `/system/backup-recovery/record/`, method: 'GET', data });
//备份列表删除可批量
export const delbackupList = (data) =>
  Fetch({ url: `/system/backup-recovery/record/`, method: 'POST', data });
//备份文件上传
export const backupActive = (data) =>
  Fetch({ url: `/system/backup-recovery/file/`, method: 'POST', data });
//备份恢复（还原）
export const backupRecover = (data) =>
  Fetch({ url: `/system/backup-recovery/recovery/`, method: 'POST', data });
//备份文件/恢复/进度
export const backupProgress = (data) =>
  Fetch({ url: `/system/backup-recovery/progress/`, method: 'GET', data, isheaders: false });
//备份文件下载
export const backupDown = (data) =>
  Fetch({
    url: `/system/backup-recovery/file/`,
    method: 'GET',
    data,
    file: false,
    blob: { responseType: 'blob' },
  });
//报表批量（导出，导出进度查询）
export const postReport = (data) => Fetch({ url: `/report/report-batch/`, method: 'POST', data });
//报表批量导出下载接口
export const getReportAll = (data) =>
  Fetch({
    url: `/report/report-batch/`,
    method: 'GET',
    data,
    file: false,
    blob: { responseType: 'blob' },
  });
//token时间查询
export const getTokenTime = (data) =>
  Fetch({
    url: `/gc/token/`,
    method: 'GET',
    data,
  });

// 搜索策略模版列表
export const getTemSearch = (data) =>
  Fetch({
    url: `/strategy/profile/template/search/`,
    method: 'GET',
    data,
  });
// 获取外网映射配置
export const getNetmap = (data) =>
  Fetch({
    url: `/warn/netmap/`,
    method: 'GET',
    data,
  });
// 更新外网映射配置
export const putNetmap = (data) =>
  Fetch({
    url: `/warn/netmap/`,
    method: 'PUT',
    data,
  });
//获取oem文案
export const getOEM = (data) =>
  Fetch({
    url: `/gc/display/`,
    method: 'GET',
    data,
    isheaders: false,
  });
/** API */
//增加授权TOKEN
export const postToken = (data) =>
  Fetch({
    url: `/user/input_token/`,
    method: 'POST',
    data,
  });
//查询授权TOKEN
export const getToken = () =>
  Fetch({
    url: `/user/input_token/`,
    method: 'GET',
  });
//修改授权TOKEN
export const putToken = ({ id, data }) =>
  Fetch({
    url: `/user/input_token/${id}/`,
    method: 'PUT',
    data,
  });
//删除授权TOKEN
export const delToken = ({ id }) =>
  Fetch({
    url: `/user/input_token/${id}/`,
    method: 'DELETE',
  });
//增加推送URL
export const postUrl = (data) =>
  Fetch({
    url: `/user/output_url/`,
    method: 'POST',
    data,
  });
//查询推送URL
export const getUrl = () =>
  Fetch({
    url: `/user/output_url/`,
    method: 'GET',
  });
//修改推送URL
export const putUrl = ({ id, data }) =>
  Fetch({
    url: `/user/output_url/${id}/`,
    method: 'PUT',
    data,
  });
//删除推送URL
export const delUrl = ({ id }) =>
  Fetch({
    url: `/user/output_url/${id}/`,
    method: 'DELETE',
  });
//测试推送URL
export const testUrl = (data) =>
  Fetch({
    url: `/user/output_url_test/`,
    method: 'GET',
    data,
  });
// 升级记录
export const updateLogApi = (data, method = 'GET') =>
  Fetch({ url: '/system/update_log/', method, data });
// 获取历史任务
export const getHistoryTask = (data, method = 'GET') =>
  Fetch({ url: '/session/list/', method, data });
// 日志设置
export const logSwitch = (data, method) => Fetch({ url: '/log/switch/', method, data });
// SSH查询设置
export const sysSSH = (data, method) => Fetch({ url: '/system/ssh/', method, data });
// 变更基准列表
export const changeList = (data) =>
  Fetch({
    url: `/strategy/change_check/`,
    method: 'GET',
    data,
  });
// 更新基准
export const changePUT = (data) =>
  Fetch({
    url: `/strategy/change_check/`,
    method: 'PUT',
    data,
  });
//删除基准、批量删除基准
export const changeDEL = (data) =>
  Fetch({
    url: `/strategy/change_check/`,
    method: 'DELETE',
    data,
  });
//报告下载-业务系统列表
export const exportTargets = (data) =>
  Fetch({
    url: `/report/targets/list`,
    method: 'GET',
    data,
  });
//报告下载-报告下载任务下发
export const exportPOST = (data) =>
  Fetch({
    url: `/report/export`,
    method: 'POST',
    data,
  });
//报告下载-报告下载列表
export const exportGET = (data) =>
  Fetch({
    url: `/report/exports/list`,
    method: 'GET',
    data,
  });
//报告下载-下载任务删除
export const exportDEL = (data) =>
  Fetch({
    url: `/report/exports/del`,
    method: 'DELETE',
    data,
  });
//报告下载-报告下载
export const exportDownload = (data) =>
  Fetch({
    url: `/report/exports/download`,
    method: 'GET',
    data,
    file: false,
    blob: { responseType: 'blob' },
  });

export const getRoleList = (query) =>
  Fetch({
    url: `/user_group/list?page=${query.page || 1}&pageSize=${query.pageSize || 10}&userGroupId=${
      query.userGroupId || ''
    }`,
    method: 'GET',
  });

export const getPermissionList = () =>
  Fetch({
    url: `/user_group/module`,
    method: 'GET',
  });

export const addRole = (data) =>
  Fetch({
    url: `/user_group/add`,
    method: 'POST',
    data,
  });

export const delRole = (data) =>
  Fetch({
    url: `/user_group/delete`,
    method: 'DELETE',
    data,
  });

export const editRole = (data) =>
  Fetch({
    url: `/user_group/modify`,
    method: 'PUT',
    data,
  });
export const getChapters = () =>
  Fetch({
    url: `/report/chapters/list`,
    method: 'GET',
  });
